@{
    ViewData["Title"] = "MeiliSearch 测试";
}

<div class="layui-card">
    <div class="layui-card-header">
        <h2>MeiliSearch 连接测试</h2>
    </div>
    <div class="layui-card-body">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md6">
                <button class="layui-btn layui-btn-normal" onclick="testSearch()">测试搜索</button>
                <button class="layui-btn layui-btn-warm" onclick="testRawSearch()">原始搜索</button>
            </div>
            <div class="layui-col-md6">
                <button class="layui-btn layui-btn-primary" onclick="testIndexSettings()">获取索引设置</button>
                <button class="layui-btn layui-btn-danger" onclick="initializeIndex()">初始化索引</button>
            </div>
        </div>
        
        <div id="result" style="margin-top: 20px;"></div>
    </div>
</div>

@section Scripts {
    <script>
        function testSearch() {
            $.get('/MeiliSearchTest/TestSearch', function(result) {
                displayResult('搜索测试', result);
            });
        }
        
        function testRawSearch() {
            $.get('/MeiliSearchTest/TestRawSearch', function(result) {
                displayResult('原始搜索测试', result);
            });
        }
        
        function testIndexSettings() {
            $.get('/MeiliSearchTest/TestIndexSettings', function(result) {
                displayResult('索引设置', result);
            });
        }
        
        function initializeIndex() {
            $.get('/MeiliSearchTest/InitializeIndex', function(result) {
                displayResult('索引初始化', result);
            });
        }
        
        function displayResult(title, result) {
            var html = '<div class="layui-card" style="margin-top: 10px;">';
            html += '<div class="layui-card-header">' + title + '</div>';
            html += '<div class="layui-card-body">';
            html += '<pre>' + JSON.stringify(result, null, 2) + '</pre>';
            html += '</div></div>';
            $('#result').html(html);
        }
    </script>
}
